package com.example.transaction.mapper;

import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.example.transaction.pojo.A;
import org.apache.ibatis.annotations.*;

import java.util.List;

//@CacheNamespace(blocking = false)禁止二级缓存
@Mapper//transaction
public interface AMapper {
    @Insert("insert into transaction_a(pname,money) values(#{et.pname},#{et.money})")
    public boolean insertA(@Param(Constants.ENTITY) A a);

    @Update("update transaction_a set money=#{money} where pname=#{pname}")
    public boolean updateAByName(@Param("pname") String name,@Param("money") Integer money);
    //useCache：不进行二级缓存。
    //flushCache：Options.FlushCachePolicy.TRUE代表关闭一级缓存
    @Options(useCache=false,flushCache = Options.FlushCachePolicy.TRUE)
    @Select("select * from transaction_a where pname=#{pname}")
    public A selectAByName(@Param("pname") String name);

    @Options(useCache=false,flushCache = Options.FlushCachePolicy.TRUE)
    @Select("select * from transaction_a")
    public List<A> selectAAll();

    @Delete("delete from transaction_a where pname=#{pname}")
    public boolean deleteAByName(@Param("pname")String name);
}
